/*
 * utilityNode.h
 *
 *  Created on: Feb 11, 2010
 *      Author: rohithdv
 */

#ifndef UTILITYNODE_H_
#define UTILITYNODE_H_

#include <iostream>
using namespace std;

class utilityNode {
private:
	int playerCount;
	double *utilityOfPlayers;
	int *strategyProfile;
	utilityNode *next;
public:
	static int numberOfTimesDestructorIsCalled;
	utilityNode() {
		strategyProfile = NULL;
		utilityOfPlayers = NULL;
	}

	~utilityNode() {
		cout << "UtilityNode destructor called " << endl;
		delete[] utilityOfPlayers;
		delete[] strategyProfile;
		next = NULL;
		utilityNode::numberOfTimesDestructorIsCalled++;
	}

	utilityNode(int *stratProfile, double *utilProfile, int noofplayers) {
		strategyProfile = new int[noofplayers];
		utilityOfPlayers = new double[noofplayers];
		playerCount = noofplayers;

		for (int i=0; i<noofplayers; i++) {
			strategyProfile[i] = stratProfile[i];
			utilityOfPlayers[i] = utilProfile[i];
		}
		next = NULL;
	}

	double getUtilityValue(int index){
		return utilityOfPlayers[index];
	}

	int *getStrategyProfile(){
		return strategyProfile;
	}

	utilityNode *setNextPointer(utilityNode *nextptr) {
		next = nextptr;
		return this;
	}
	utilityNode *getNextNode() { return next;}

	void display() {
		cout << endl;
		cout << "[" ;
		for (int g=0;g <playerCount; g++) {
			cout << strategyProfile[g] << " ";
		}
		cout << "] : {" ;
		for (int g=0;g <playerCount; g++) {
			cout << utilityOfPlayers[g] << "  ";
		}
		cout << "}";
	}
};

#endif /* UTILITYNODE_H_ */

